<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        var i = 100;    // 全局
        function fn() {
            i = 20;
            console.log(i);
            for (var i = 0; i < 10; i++) {
                console.log(i);
            }
            console.log(this);
            console.log(this.i);    // 全局的i
            console.log(i);
        }
        fn()
        console.log(i);

    </script>

</body>

</html>